1 package net.sourceforge.selfesteem.applet;
2
3 import javax.swing.*;
4 import javax.swing.border.EmptyBorder;
5 import javax.swing.table.TableCellRenderer;
6 import java.awt.*;
7
8 public class ProgressBarRenderer extends JProgressBar implements TableCellRenderer {
9 private JLabel _emptyLabel = new JLabel();
10 private JPanel _progressPanel = new JPanel();
11
12
13 public ProgressBarRenderer() {
14 setMinimum(0);
15 setMaximum(100);
16 setBackground(Color.red);
17 setForeground(Color.green);
18 setMinimumSize(new Dimension(150, 20));
19
20 _progressPanel.setBackground(Color.white);
21 _progressPanel.setBorder(new EmptyBorder(5, 0, 5, 0));
22 _progressPanel.setLayout(new BorderLayout());
23 _progressPanel.add(this, BorderLayout.CENTER);
24 }
25
26 public Component getTableCellRendererComponent(JTable table, Object value,
27 boolean isSelected, boolean hasFocus,
28 int row, int column) {
29 if (value == null) return _emptyLabel;
30
31 this.setValue(((Integer) value).intValue());
32 return _progressPanel;
33 }
34 }
This page was automatically generated by Maven